function TrProgressGui(prefix, tableRow, item, options) {
  this._prefix = prefix;
  this._tableRow = tableRow;
  this._item = item;
  
  this._music = (options && options.music) ? options.music : null;
  this._precon = (options && options.precon) ? options.precon : null;
  this._photographer = (options && options.photographer) ? options.photographer : null;
  this._videographer = (options && options.videographer) ? options.videographer : null;
  this._makeup = (options && options.makeup) ? options.makeup : null;
  this._produce = (options && options.produce) ? options.produce : null;
  this._video = (options && options.video) ? options.video : null;
  this._p4x6 = (options && options.p4x6) ? options.p4x6 : null;
  this._pretouch = (options && options.pretouch) ? options.pretouch : null;
  this._pcommon = (options && options.pcommon) ? options.pcommon : null;
  
  this._registrar = (options && options.registrar) ? options.registrar : null;
  this._createElements();
};

TrProgressGui.prototype._createElements = function() {
  var td, div, itable, itr, itd;
  
  var ttd = this._tableRow.insertCell(-1);
  ttd.style.verticalAlign = 'top';
  var topBig = document.createElement('table');
  topBig.style.backgroundImage = 'url(images/pageasst/trprogress/topback.png)';
  topBig.style.backgroundRepeat = 'no-repeat';
  topBig.style.width = '669px';
  topBig.style.height = '15px';
  topBig.cellPadding = 0;
  topBig.cellSpacing = 0;
  ttd.appendChild(topBig);
  
  var middleBig = document.createElement('table');
  middleBig.style.backgroundImage = 'url(images/pageasst/trprogress/middleback.png)';
  middleBig.style.backgroundRepeat = 'repeat-y';
  middleBig.style.width = '669px';
  middleBig.style.height = '50px';
  middleBig.cellPadding = 0;
  middleBig.cellSpacing = 0;
  ttd.appendChild(middleBig);
  
  var mtr = middleBig.insertRow(-1);
  mtd = mtr.insertCell(-1);
  mtd.style.verticalAlign = 'top';
  var table = document.createElement('table');
  table.cellPadding = 0;
  table.cellSpacing = 0;
  mtd.appendChild(table);
  
  var tr = table.insertRow(-1);
  td = tr.insertCell(-1);
  td.style.width = '35px';
  td.style.verticalAlign = 'top';
  td.style.textAlign = 'center';
  var img = document.createElement('img');
  img.src = 'images/pageasst/trprogress/customer.png';
  td.appendChild(img);
  td = tr.insertCell(-1);
  td.style.width = '78px';
  td.style.textAlign = 'center';
  td.style.verticalAlign = 'middle';
  td.style.fontSize = '14px';
  td.style.fontWeight = 'bold';
  td.style.fontFamily = 'Tahoma';
  var back = document.createElement('table');
  back.style.backgroundImage = 'url(images/pageasst/trprogress/cidback.png)';
  back.style.backgroundRepeat = 'no-repeat';
  back.style.width = '70px';
  back.style.height = '27px';
  back.style.margin = '0 0 0 5px';
  btr = back.insertRow(-1);
  btd  = btr.insertCell(-1);
  btd.style.textAlign = 'center';
  btd.style.verticalAlign = 'middle';
  btd.appendChild(document.createTextNode('#' + this._item.id));
  td.appendChild(back);
  
  td = tr.insertCell(-1);
  td.style.width = '500px';
  td.style.verticalAlign = 'middle';
  td.style.textAlign = 'center';
  
  
  for (var i = 0, il = this._item.orders.length; i < il; i++) {
    var order = this._item.orders[i];
    
    if (i != 0) {
      var btable = document.createElement('table');
      btable.style.height = '20px';
      td.appendChild(btable);
    }
    
    var otable = document.createElement('table');
    otable.style.height = '30px';
    otable.cellPadding = 0;
    otable.cellSpacing = 0;
    td.appendChild(otable);
    
    otr = otable.insertRow(-1);
    otd = otr.insertCell(-1);
    otd.style.verticalAlign = 'middle';
    otd.style.fontWeight = 'bold';
    otd.style.fontSize = '16px';
    otd.style.color = '#0099ff';
    var img = document.createElement('img');
    img.src = 'images/pageasst/trprogress/order.png';
    img.style.margin = '0 5px 0 0 ';
    otd.appendChild(img);
    var span = document.createElement('span');
    span.appendChild(document.createTextNode(i+1));
    otd.appendChild(span);
    
    var top = document.createElement('table');
    top.style.backgroundImage = 'url(images/pageasst/trprogress/intopback.png)';
    top.style.backgroundRepeat = 'no-repeat';
    top.style.width = '515px';
    top.style.height = '10px';
    top.cellPadding = 0;
    top.cellSpacing = 0;
    td.appendChild(top);
    
    itable = document.createElement('table');
    itable.style.backgroundImage = 'url(images/pageasst/trprogress/inmiddleback.png)';
    itable.style.backgroundRepeat = 'repeat-y';
    itable.style.width = '515px';
    itable.style.height = '30px';
    itable.cellPadding = 0;
    itable.cellSpacing = 0;
    td.appendChild(itable);
    
    var bottom = document.createElement('table');
    bottom.style.backgroundImage = 'url(images/pageasst/trprogress/inbottomback.png)';
    bottom.style.backgroundRepeat = 'no-repeat';
    bottom.style.width = '515px';
    bottom.style.height = '10px';
    bottom.cellPadding = 0;
    bottom.cellSpacing = 0;
    td.appendChild(bottom);
    
    if (this._music) {
      itr = itable.insertRow(-1);
      itd = itr.insertCell(-1);
      itd.style.width = '15px';
      itd = itr.insertCell(-1);
      var img = document.createElement('img');
      img.src = 'images/pageasst/trprogress/music.png';
      itd.appendChild(img);
      itd = itr.insertCell(-1);
      itd.id = 'itd' + this._prefix + i + '1';
    }
    
    if (this._precon) {
      itr = itable.insertRow(-1);
      itd = itr.insertCell(-1);
      itd.style.width = '15px';
      itd = itr.insertCell(-1);
      var img = document.createElement('img');
      img.src = 'images/pageasst/trprogress/precon.png';
      itd.appendChild(img);
      itd = itr.insertCell(-1);
      itd.id = 'itd' + this._prefix + i + '2';
    }
    for (var j = 0, jl = order.tasks.length; j < jl; j++) {
      var task = order.tasks[j];
      /*
      itr = itable.insertRow(-1);
      itd = itr.insertCell(-1);
      itd.style.width = '20px';
      itd = itr.insertCell(-1)
      itd.style.height = '10px';
      itd.colSpan = 3;
      itd.style.textAlign = 'left';
      var img = document.createElement('img');
      img.src = 'images/pageasst/trprogress/task.png';
      itd.appendChild(img);
      itd.appendChild(document.createTextNode( '( ' + SimpleDate.format(task.date) + ' )'));
      */
      if (this._photographer) {
        for (var k = 0, kl = task.photographers.length; k < kl; k++) {
          var photographer = task.photographers[k];
          itr = itable.insertRow(-1);
          itd = itr.insertCell(-1);
          itd.style.width = '20px';
          itd.style.height = '10px';
          itd = itr.insertCell(-1);
          itd.style.width = '100px';
          itd.style.textAlign = 'left';
          var img = document.createElement('img');
          img.src = 'images/pageasst/trprogress/photographer.png';
          itd.appendChild(img);
          itd.appendChild(document.createTextNode((photographer.assignee) ? ' (' + photographer.assignee.account + ')' : ''));
          itd = itr.insertCell(-1);
          itd.id = 'itd' + this._prefix + i + j + k + '3';
        }
      }
      if (this._videographer) {
        for (var k = 0, kl = task.videographers.length; k < kl; k++) {
          var videographer = task.videographers[k];
          itr = itable.insertRow(-1);
          itd = itr.insertCell(-1);
          itd.style.height = '10px';
          itd = itr.insertCell(-1);
          itd.style.textAlign = 'left';
          var img = document.createElement('img');
          img.src = 'images/pageasst/trprogress/videographer.png';
          itd.appendChild(img);
          itd.appendChild(document.createTextNode((videographer.assignee) ? ' (' + videographer.assignee.account + ')' : ''));
          itd = itr.insertCell(-1);
          itd.id = 'itd' + this._prefix + i + j + k + '4';
        }
      }
      if (this._makeup) {
        for (var k = 0, kl = task.makeups.length; k < kl; k++) {
          var makeup = task.makeups[k];
          itr = itable.insertRow(-1);
          itd = itr.insertCell(-1);
          itd.style.height = '10px';
          itd = itr.insertCell(-1);
          itd.style.textAlign = 'left';
          var img = document.createElement('img');
          img.src = 'images/pageasst/trprogress/makeup.png';
          itd.appendChild(img);
          itd.appendChild(document.createTextNode((makeup.assignee) ? ' (' + makeup.assignee.account + ')' : ''));
          itd = itr.insertCell(-1);
          itd.id = 'itd' + this._prefix + i + j + k + '5';
        }
      }
    }
    
    for (var m = 0, ml = order.produces.length; m < ml; m++) {
      var produce = order.produces[m];
      if (!this._produce) {
        if (produce.product.model == '{{$smarty.const.MODEL_NAME_PRODUCT_VIDEO|escape:javascript}}' && !this._video) {
          continue;
        } else if (produce.product.model == '{{$smarty.const.MODEL_NAME_PRODUCT_4X6|escape:javascript}}' && !this._p4x6) {
          continue;
        } else if (produce.product.model == '{{$smarty.const.MODEL_NAME_PRODUCT_RETOUCH|escape:javascript}}' && !this._pretouch) {
          continue;
        } else if (produce.product.model == '{{$smarty.const.MODEL_NAME_PRODUCT_COMMON|escape:javascript}}' && !this._pcommon) {
          continue;
        }
      }
      
      if (this._registrar.type == '{{$smarty.const.USER_TYPE_DESIGNER|escape:javascript}}' && this._registrar.id != produce.assignee.userId) {
        continue;
      }
      
      itr = itable.insertRow(-1);
      itd = itr.insertCell(-1);
      itd.style.width = '10px';
      itd = itr.insertCell(-1);
      itd.style.textAlign = 'left';
      itd.appendChild(document.createTextNode(produce.product.name + ((produce.assignee.userId) ? ' (' + produce.assignee.account + ')' : '')));
      itd = itr.insertCell(-1);
      itd.id = 'itd' + this._prefix + i + m + '6';
    }
  }
  
  var bottomBig = document.createElement('table');
  bottomBig.style.backgroundImage = 'url(images/pageasst/trprogress/bottomback.png)';
  bottomBig.style.backgroundRepeat = 'no-repeat';
  bottomBig.style.width = '669px';
  bottomBig.style.height = '15px';
  bottomBig.cellPadding = 0;
  bottomBig.cellSpacing = 0;
  ttd.appendChild(bottomBig);
};